import request from '@/utils/request'

// 获取角色列表
export const getUserList = (page, limit, keyword) =>
  request({
    url: `/admin/acl/user/${page}/${limit}`,
    method: 'get',
    params: { username: keyword }
  })

// 添加用户
export const addOrupdataUserInfo = (data) =>
  request({
    url: data.id ? `/admin/acl/user/update` : `/admin/acl/user/save`,
    method: data.id ? 'put' : 'post',
    data
  })

// 删除用户
export const delUserInfo = (id) =>
  request({ url: `/admin/acl/user/remove/${id}`, method: 'delete' })

// 批量删除用户

export const deluserList = (idList) =>
  request({
    url: `/admin/acl/user/batchRemove`,
    method: 'delete',
    data: idList
  })

// 获取用户角色列表
export const getUseroleList = (userId) =>
  request({ url: `/admin/acl/user/toAssign/${userId}`, method: 'get' })

// 跟新用户角色列表
export const updataUserRoleList = (userId, roleIdList) => {
  let roleId = roleIdList.join(',')
  return request({
    url: `/admin/acl/user/doAssign`,
    method: 'post',
    params: { userId, roleId }
  })
}
